const db = wx.cloud.database();
const app = getApp();
Page({
  data: {
    
  },
  onLoad: function (options) {
    var that = this;
    console.log(options);
    that.setData({
      area: options.area,
      geneal: options.agent
    })
    if(options.page){
        that.setData({
            page:options.page
        })
    }

  },
  getPhoneNumber(e) {
    var that = this;
        wx.cloud.callFunction({
            name: 'getMobile',
            data: {
                weRunData: wx.cloud.CloudID(e.detail.cloudID),
            }
        }).then(res => {
            that.setData({
                mobile: res.result,
            })
            wx.setStorageSync('phone', res.result)
            console.log(res.result)
            wx.request({ //发送请求
                url: "https://zg99.offcn.com/index/biaodan/register/?actid=42173&callback=?",
                data: {
                    phone: res.result,
                    fenxiao: that.data.area,
                    geneal: that.data.geneal
                }, //接收参数
                success(res) { //返回
                    var jsonStr = res.data;
                    jsonStr = jsonStr.replace("(", "");
                    jsonStr = jsonStr.replace(")", "");
                    if (typeof jsonStr != 'object') {
                        jsonStr = jsonStr.replace(/\ufeff/g, ""); //字符串转化JSON对象
                        var theJson = JSON.parse(jsonStr);
                    };
                    console.log(theJson)
                    wx.navigateTo({
                      url: '../weblink/weblink'
                    })

                }
            })
            wx.request({
                url: 'https://tgadmin.sdwx.zgkfpt.cn/api/v1/collect_v3',
                method: 'POST',
                data: {
                  activeId: 30,
                  mobile: res.result,
                  areaCode: that.data.area,
                  agent: that.data.geneal,
                  pageId: that.data.page
                },
                success: res => {
                  console.log(res);
                }
              })
            

        }).catch(err => {
            console.error(err);
        });
},

})